#
#    Copyright (C) 2013  Charles-Eugene LOUBAO
#
#    This program is free software: you can redistribute it and/or modify
#    it under the terms of the GNU General Public License as published by
#    the Free Software Foundation, either version 3 of the License, or
#    (at your option) any later version.
#
#    This program is distributed in the hope that it will be useful,
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#    GNU General Public License for more details.
#
#    You should have received a copy of the GNU General Public License
#    along with this program.  If not, see <http://www.gnu.org/licenses/>.
#

VERSION_MAJOR := 1
VERSION_MINOR := 3
SUBVERSION := 0
VERSION_STATE :=
SOURCE_DIR  := src
OBJECT_DIR  := obj
OUT_DIR	    := out
  
all :	binary

main.o :
	@echo ""
	@echo "--------------------------------------------"
	@echo "--- pythonswitcher compiler"
	@echo "--- Version to compile : $(VERSION_MAJOR).$(VERSION_MINOR).$(SUBVERSION)$(VERSION _STATE)"
	@echo "--------------------------------------------"
	@echo "Making needed folders"
	mkdir out
	mkdir obj
	@echo ""
	@echo "Compiling object files"
	gcc -c  $(SOURCE_DIR)/main.c -o $(OBJECT_DIR)/pythonswitcher.o
	@echo ""
	@echo "Object files compiled"
	@echo ""

binary :main.o
	@echo ""
	@echo "Linking object files ..."
	gcc $(OBJECT_DIR)/pythonswitcher.o -o $(OUT_DIR)/pythonswitcher
	@echo ""
	@echo "Binary compiled"
	@echo "Output file : out/pytonswitcher"
	@echo ""

install :
	@echo ""
	@echo "Removing eventually previous version of pythonswitcher"
	rm -f /opt/pythonswitcher
	rm -f /usr/local/bin/pythonswitcher
	@echo ""
	@echo "Copying binary to /usr/local/bin"
	cp $(OUT_DIR)/pythonswitcher /usr/local/bin
	@echo ""
	@echo "succefully installed"
	@echo "Access the app by typing in a terminal :"
	@echo "sudo pythonswitcher"
	@echo ""

clean	:
	@echo ""
	@echo "Cleaning... "
	rm -f -r out
	rm -f -r obj
	@echo ""
	@echo "source directory cleaned"
	@echo ""

newbuild    :
	make clean
	make
